<?php
/**
 * User Parameters Dropdown Button, to display the following links :
 * <ul>
 * <li>Preferences</li>
 * <li>Logout</li>
 * </ul>
 *
 * @author Xavier VILAIN
 * @package Fox
 * @license
 */
use Fox\Msg;
$user = User::current();
$xview = \Xview::instance();
$colorClass = $xview->val('colorclass','btn-primary');
$colorClass = 'btn-warning';
if(is_object($user))
{
	$usrnm = $user->getUserName();
	if(empty($usrnm))
	{
		$usrnm = $user->email();
	}
	$id = $user->getId();
	$switchBack = null;
	// Check if a switch mode in active
	if(isset($_SESSION['mdusr']) && !empty($_SESSION['mdusr']))
	{
		$switchBack = '<li><a href="?mod=admin&act=switch&mode=true">'.Msg(Msg::BUNDLE,Msg::MSG_SWITCH_BACK).'</a></li>';
	}
    $body = '<ul class="nav pull-right user-params-full">
    			<div class="btn-group hidden-phone">
    				<a class="btn '.$colorClass.'" style="color:black!important" href="?mod=users&act=preferences&sac=show">
    					<i class="icon-user icon-black"></i>
    					'.$usrnm.'
    				</a>
    				<a class="btn '.$colorClass.'  dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret" style="border-top-color: black!important;"></span></a>
    				<ul class="dropdown-menu pull-right">
    					<li><a href="?mod=users&act=main"><i class="icon-pencil"></i> '.Msg(Msg::BUNDLE,Msg::MSG_PREFERENCES).'</a></li>
    					'.$switchBack.'
    					<li class="divider"></li>
    					<li><a href="?mod=core&act=login&sac=signout&logout=true" id="logout"><i class="icon-eject"></i> '.Msg(Msg::BUNDLE,Msg::MSG_LOGOUT).'</a></li>
    				</ul>
    			</div>
    			
    		</ul>
    		<div class="visible-phone user-params">
    				<a class="btn '.$colorClass.' dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret" style="border-top-color: black;"></span></a>
    				<ul class="dropdown-menu pull-right">
    					<li><a href="?mod=users&act=main"><i class="icon-pencil"></i> '.Msg(Msg::BUNDLE,Msg::MSG_PREFERENCES).'</a></li>
    					'.$switchBack.'
    					<li class="divider"></li>
    					<li><a href="?mod=core&act=login&sac=signout&logout=true" id="logout"><i class="icon-eject"></i> '.Msg(Msg::BUNDLE,Msg::MSG_LOGOUT).'</a></li>
    				</ul>
    		</div>
    		<span class="cright"></span>';
   	return $body;
}